package ru.urfc.portal.ui.client.widgets;

import ru.urfc.portal.ui.client.BaseGooglet;

import com.extjs.gxt.ui.client.widget.form.TextField;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Widget;

public class ClientFilter extends BaseFilter {

	interface Binder extends UiBinder<Widget, ClientFilter> {}
	private static Binder binder = GWT.create(Binder.class);

	@UiField BranchFilter branchFilter;
	@UiField TextField<String> name;
	@UiField TextField<String> inn;
	@UiField TextField<String> ogrn;
	@UiField Element placeForSearchButton;

	public ClientFilter() {
		initWidget(binder.createAndBindUi(this));
		this.descriptor = branchFilter.descriptor;//TODO  it's temporary hack
		this.itemsController = branchFilter.itemsController;// 
		descriptor.addTextField(FILTER_CLIENT_NAME, name);
		descriptor.addTextField(FILTER_CLIENT_INN, inn);
		descriptor.addTextField(FILTER_CLIENT_OGRN, ogrn);
	}
	
	public TextField<String> getName() {
		return name;
	}
	
	public TextField<String> getInn() {
		return inn;
	}
	
	public TextField<String> getOgrn() {
		return ogrn;
	}

	public void init(BaseGooglet googlet) {
		branchFilter.init(googlet);
	}
	
	@Override
	protected Element getPlaceForSearchButton() {
		return placeForSearchButton;
	}
	
}